file chooser: Don't leave out icons by accident
authorMatthias Clasen <mclasen@redhat.com>
Mon, 3 Aug 2015 00:42:42 +0000 (20:42 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 3 Aug 2015 00:51:12 +0000 (20:51 -0400)
We only load thumbnails when we find that the row is in the visible
range of the treeview. It seems that animated scrolling makes it so
that the bottommost row stays out of the visible range until it is
too late. To work around this, extend the range by one row in each
direction.

http://bugzilla.gnome.org/show_bug.cgi?id=753142

gtk/gtkfilechooserwidget.c

index 84dc97083326d3145d90e190199817f47670874e..ce54b14475b4608b09f9e67abc1b6910bb349221 100644 (file)
@@ -4911,8 +4911,9 @@ file_system_model_set (GtkFileSystemModel *model,
           else
             {
               GtkTreeModel *tree_model;
-              GtkTreePath *path, *start, *end;
+              GtkTreePath *start, *end;
               GtkTreeIter iter;
+              gboolean visible;
 
               if (priv->browse_files_tree_view == NULL ||
                   g_file_info_has_attribute (info, "filechooser::queried"))
@@ -4922,15 +4923,25 @@ file_system_model_set (GtkFileSystemModel *model,
               if (tree_model != GTK_TREE_MODEL (model))
                 return FALSE;
 
-              if (!_gtk_file_system_model_get_iter_for_file (model,
-                                                             &iter,
-                                                             file))
+              if (!_gtk_file_system_model_get_iter_for_file (model, &iter, file))
                 g_assert_not_reached ();
-              if (!gtk_tree_view_get_visible_range (GTK_TREE_VIEW (priv->browse_files_tree_view), &start, &end))
-                return FALSE;
-              path = gtk_tree_model_get_path (tree_model, &iter);
-              if (gtk_tree_path_compare (start, path) != 1 &&
-                  gtk_tree_path_compare (path, end) != 1)
+
+              if (gtk_tree_view_get_visible_range (GTK_TREE_VIEW (priv->browse_files_tree_view), &start, &end))
+                {
+                  GtkTreePath *path;
+
+                  gtk_tree_path_prev (start);
+                  gtk_tree_path_next (end);
+                  path = gtk_tree_model_get_path (tree_model, &iter);
+                  visible = gtk_tree_path_compare (start, path) != 1 &&
+                            gtk_tree_path_compare (path, end) != 1;
+                  gtk_tree_path_free (path);
+                  gtk_tree_path_free (start);
+                  gtk_tree_path_free (end);
+                }
+              else
+                visible = TRUE;
+              if (visible)
                 {
                   g_file_info_set_attribute_boolean (info, "filechooser::queried", TRUE);
                   g_file_query_info_async (file,
@@ -4943,9 +4954,6 @@ file_system_model_set (GtkFileSystemModel *model,
                                            file_system_model_got_thumbnail,
                                            model);
                 }
-              gtk_tree_path_free (path);
-              gtk_tree_path_free (start);
-              gtk_tree_path_free (end);
               return FALSE;
             }
         }